{include file="common/header"/}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body">
            <div class="layui-row">
              <form action="" class="layui-form layui-form-pane" lay-filter="form">

                <div class="layui-form-item">
                    <label class="layui-form-label">父级</label>
                    <div class="layui-input-inline">
                        <select name="pid" lay-verify="required" lay-filter="pid">
                            <option value="0">默认顶级</option>
                            {volist name="categorys" id="vo"}
                            <option value="{$vo.id}" {if $parentid == $vo.id } selected {/if} >{$vo.ltitle}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">栏目名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="title" lay-verify="required" placeholder="栏目名称" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        *
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">栏目别名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="catdir" lay-verify="required" placeholder="栏目别名" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        *
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">栏目图片</label>
                    <input type="hidden" name="image" id="image" class="attach">
                    <div class="layui-input-block">
                        <div class="layui-upload">
                            <button type="button" class="layui-btn layui-btn-primary"  id="selectAttach" data-href="{:url('sys.attach/select')}?mime=image"><i class="icon icon-upload3"></i>选择</button>
                            <div class="layui-upload-list">
                                <img class="layui-upload-img" style="width: 120px; height: 100px;" id="cateImage">
                                <p id="demoText"></p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">SEO标题</label>
                    <div class="layui-input-inline">
                        <input type="text" name="seo_title" placeholder="{:lang('pleaseEnter')}SEO标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">SEO关键字</label>
                    <div class="layui-input-inline">
                        <input type="text" name="seo_keywords" placeholder="{:lang('pleaseEnter')}SEO关键字" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">SEO描述</label>
                    <div class="layui-input-inline">
                        <textarea placeholder="{:lang('pleaseEnter')}SEO描述" name="seo_desc" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">分页条数</label>
                        <div class="layui-input-inline">
                            <input type="number" name="pagesize" value="20" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">为空时默认值为系统设置的值</div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="cateInsertSubmit">立即提交</button>
                    </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

{include file="common/footer"/}
<script>
var layForm;
layui.use(['form', 'layer'], function(){
    var layer = layui.layer,$= layui.jquery;
    layForm = layui.form;
    var info  = {:json_encode($info)};
    if(info){
        layForm.val('form',info);
    }

    layForm.on('submit(cateInsertSubmit)', function (data) {
        var loading = layer.load(1, {shade: [0.1, '#fff']});
        $.post("{:url('save')}", data.field, function (res) {
            layer.close(loading);
            if (res.code > 0) {
                layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                    window.parent.location.href = res.url;
                });
            } else {
                layer.msg(res.msg, {time: 1800, icon: 2});
            }
        });
    });
});

</script>